/**
 * 260. 只出现一次的数字 III
 */
public class No260 {
    public int[] singleNumber(int[] nums) {
        int x = 0;
        for (int num : nums) x ^= num;
        int k = x & (~x + 1);

        int[] ans = new int[2];
        for (int num : nums) {
            if ((num & k) == 0) ans[0] ^= num;
            else ans[1] ^= num;
        }
        return ans;
    }
}
